import 'package:flutter/material.dart';
import 'card.dart';
class InputPage extends StatefulWidget {
  InputPage({Key key, this.title,this.para}) : super(key: key);
  final String title;
  final Map<String,dynamic> para;
  @override
  _InputPage createState() => _InputPage();
}

class _InputPage extends State<InputPage> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  var name = "";
  int sex = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Padding(padding: EdgeInsets.all(20),child: Column(
        children: <Widget>[
          Text("請輸入姓名及性別",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 21),),
          SizedBox(
            height: 20,
          ),
          Row(
            children: <Widget>[
              Text("姓名",style: TextStyle(fontWeight: FontWeight.bold)),
              SizedBox(
                width: 30,
              ),
              Expanded(child: TextField(onChanged: (str){
                this.name = str;
              },),),
              SizedBox(
                width: 30,
              ),
              Text("性别",style: TextStyle(fontWeight: FontWeight.bold)),
              SizedBox(
                width: 30,
              ),
              Radio(
                  value: 0,
                  groupValue: this.sex,
                  onChanged: (str) {
                    setState(() {
                      sex = 0;
                    });
                  }),
              Text("先生",style: TextStyle(fontWeight: FontWeight.bold)),
              SizedBox(
                width: 30,
              ),
              Radio(
                  value: 1,
                  groupValue: this.sex,
                  onChanged: (str) {
                    setState(() {
                      sex = 1;
                    });
                  }),
              Text("女士",style: TextStyle(fontWeight: FontWeight.bold)),
              SizedBox(
                width: 30,
              ),
              Radio(
                  value: 2,
                  groupValue: this.sex,
                  onChanged: (str) {
                    setState(() {
                      sex = 2;
                    });
                  }),
              Text("太太",style: TextStyle(fontWeight: FontWeight.bold)),
              SizedBox(
                width: 30,
              ),
            ],
          ),
          SizedBox(
            height: 20,
          ),
          Align(alignment: Alignment.centerLeft,child: MaterialButton(
            materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
            height: 40,
            minWidth: 100,
            padding: EdgeInsets.all(0),
            color: Color(0xff4a701e),
            textColor: Colors.white,
            shape: RoundedRectangleBorder(
                borderRadius:
                BorderRadius.all(Radius.circular(20))),
            onPressed: () {
              var dic = widget.para;
              dic["gender"] = this.sex + 1;
              dic["visitor_name"] = this.name;
              Navigator.push( context, MaterialPageRoute(builder: (context) => CardPage(title: widget.title,para: dic)),);
            },
            child: Text("下一步"),
          ),),
        ],
      ),),
    );
  }
}